home *** CD-ROM | disk | FTP | other *** search
Wrap
Text File | 1993-10-08 | 2.8 KB | 95 lines | [ TEXT/MPAD]
-- calculate great circle routes places = {Anchorage, BuenosAires, CapeTown, Honolulu, London, Moscow, NewYork, Singapore, Sydney, Tokyo, Wellington} here=London; there=Anchorage az := heading(here,there):; az:-15.6 alpha := angle(here,there):; distance(alpha):4457.0 -- For a nice background, use the world map picture from the system 7 distribution Scrapbook File. Paste it into the PLOT and comment out the following line. plot place(places) plot place({here}) s := rotation(here[1],here[2],90): inc := multiply(rotation(incangle,0,az),rotation(0,0,-az)): plot {step,c[1]}; plot place({there}) step = r:={1,0,0} when X=0, r:=transform(inc,r), b:=transform(s,r), c:=geog(b), c[2] place(L)[i] = {L[i,2],L[i,1]} -- swap for plot. X=lon Y=lat increment=300; incangle=increment/LenPerDeg Xmin=-180; Xmax=180; Xsteps=trunc(alpha/incangle) Ymin= -89; Ymax= 89 -- locations are given in {+N latitude, +E longitude} degrees. Anchorage ={ 61,-150} BuenosAires={-35,- 58} CapeTown ={-34, 18} Honolulu ={ 21,-157} London ={ 52, 0} Moscow ={ 56, 38} NewYork ={ 41,- 74} Singapore ={ 1, 103} Sydney ={-34, 151} Tokyo ={ 36, 140} Wellington ={-41, 174} -- the great circle heading from A to B -- is the azimuth of B-A at A heading(A,B) = azimuth(head(A,B)) -- the arc length of an angle A distance(A) = A*LenPerDeg LenPerDeg = radius*π/180 -- the radius of earth (pick distance units) radius = 3960 -- azimuth is measured east of north -- in the spherical system V[2] is south, V[3] is east azimuth(V) = atan2(V[3],-V[2]) -- B-A at A head(A,B) = rotate(A[2],-A[1],-90,cart(B)-cart(A)) -- angle between locations A and B angle(A,B) = acos(sum(cart(A)[i]*cart(B)[i],i,1,3)) -- cartesian coordinates for unit vector at A={lat,lon} cart(A) = {sin(90-A[1])*cos(A[2]),sin(90-A[1])*sin(A[2]),cos(90-A[1])} -- {lat,lon} of cartesian unit vector A geog(A) = {90-acos(A[3]),atan2(A[2],A[1])} atan2(y,x) = 0 when x=0 and y=0, atan(y/x) when x>=0, atan(y/x)+180 when y>=0, atan(y/x)-180 -- the vector V in a system rotated by yaw, pitch, and roll rotate(yaw,pitch,roll,V) = transform(rotation(yaw,pitch,roll),V) rotation(y,p,r) = {{cos(p)* cos(y), cos(p)* sin(y), -sin(p) }, {sin(p)*sin(r)*cos(y)-cos(r)*sin(y), sin(p)*sin(r)*sin(y)+cos(r)*cos(y), cos(p)*sin(r) }, {sin(p)*cos(r)*cos(y)+sin(r)*sin(y), sin(p)*cos(r)*sin(y)-sin(r)*cos(y), cos(p)*cos(r) }} transform(A,V)[i] = sum(A[i,k]*V[k],k,1,count(V)) dim [count(A)] multiply(A,B)[i,j] = sum(A[i,k]*B[k,j],k,1,count(B)) dim [count(A),count(B[1])] transpose(A)[i,j] = A[j,i] dim [count(A[1]),count(A)]